package com.hundredapp.oa.domain;

import static javax.persistence.GenerationType.IDENTITY;

import java.sql.Timestamp;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 * OaPayment entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "oa_contract", catalog = "oa_demo")
public class OaContract implements java.io.Serializable {

	// Fields

	private Integer id;
	private String number;
	private Double payables;
	private Double disbursements;
	private Integer method;
	private Timestamp payTime;
	private OaUser createUser;
	private Timestamp createTime;
	private Integer state;
	private List<OaStudent> oaStudents;
	

	private List<OaElect> elects;

	// Constructors

	/** default constructor */
	public OaContract() {
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "number", length = 45)
	public String getNumber() {
		return this.number;
	}

	public void setNumber(String number) {
		this.number = number;
	}

	@Column(name = "payables", precision = 22, scale = 0)
	public Double getPayables() {
		return this.payables;
	}

	public void setPayables(Double payables) {
		this.payables = payables;
	}

	@Column(name = "disbursements", precision = 22, scale = 0)
	public Double getDisbursements() {
		return this.disbursements;
	}

	public void setDisbursements(Double disbursements) {
		this.disbursements = disbursements;
	}

	@Column(name = "method")
	public Integer getMethod() {
		return this.method;
	}

	public void setMethod(Integer method) {
		this.method = method;
	}

	@Column(name = "pay_time", length = 19)
	public Timestamp getPayTime() {
		return this.payTime;
	}

	public void setPayTime(Timestamp payTime) {
		this.payTime = payTime;
	}


	@Column(name = "create_time", length = 19)
	public Timestamp getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Timestamp createTime) {
		this.createTime = createTime;
	}
	
	@OneToMany(cascade = {CascadeType.ALL}, fetch = FetchType.LAZY, mappedBy = "oaContract")
	public List<OaElect> getElects() {
		return elects;
	}

	public void setElects(List<OaElect> elects) {
		this.elects = elects;
	}

	@ManyToMany(cascade ={CascadeType.REFRESH,CascadeType.MERGE,CascadeType.PERSIST}, fetch = FetchType.LAZY)
	@JoinTable(name = "oa_student_contract", catalog = "oa_demo", joinColumns = { @JoinColumn(name = "contract_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "student_id", nullable = false, updatable = false) })
	public List<OaStudent> getOaStudents() {
		return oaStudents;
	}

	public void setOaStudents(List<OaStudent> oaStudents) {
		this.oaStudents = oaStudents;
	}

	@OneToOne(cascade={CascadeType.ALL}) 
	@JoinColumn(name="create_user_id") 
	public OaUser getCreateUser() {
		return createUser;
	}

	public void setCreateUser(OaUser createUser) {
		this.createUser = createUser;
	}

	@Column(name = "state")
	public Integer getState() {
		return state;
	}

	public void setState(Integer state) {
		this.state = state;
	}
}